
#include "init.h"
#include "../teximage/keys.h"


////////////////////////////////////////////////////////////////////////////////
void keybfuncx( int c, bool press )
{
    uchar mpr = 0;

    if( c == SDLK_UP )              mpr |= man::BTN_NORTH;
    else if( c == SDLK_DOWN )       mpr |= man::BTN_SOUTH;
    else if( c == SDLK_LEFT )       mpr |= man::BTN_WEST;
    else if( c == SDLK_RIGHT )      mpr |= man::BTN_EAST;
    else if( c == SDLK_LSHIFT )     mpr |= man::BTN_ACT_A;
    else if( c == SDLK_LCTRL )      mpr |= man::BTN_ACT_B;

    else if( c == GW.CW._profile._key_north )   mpr |= man::BTN_NORTH;
    else if( c == GW.CW._profile._key_south )   mpr |= man::BTN_SOUTH;
    else if( c == GW.CW._profile._key_west )    mpr |= man::BTN_WEST;
    else if( c == GW.CW._profile._key_east )    mpr |= man::BTN_EAST;

    else if( c == GW.CW._profile._key_a )       mpr |= man::BTN_ACT_A;
    else if( c == GW.CW._profile._key_b )       mpr |= man::BTN_ACT_B;

    if(mpr) {
        binstream* bin = GW._ctrl.push_cmd();
        if(bin)
            *bin << (uchar)( press ? (man::fBTN_PRESS|mpr) : mpr );
    }
}

void keybfunc( int c )
{
    keybfuncx( c, true );
}

void keybupfunc( int c )
{
    keybfuncx( c, false );
}

void keyfunc( int c )
{
    GW.draw_screen(c);
}